 <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="{:U('Index/index')}">首页</a><span class="crumb-step">&gt;</span><span class="crumb-step">&gt;</span><span>微信导航设置</span></div>
        </div>
        </div>
		
		<style>
		  .result-content table th,.result-content table td{
 text-align:center;
}
		</style>
       
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="{:U('Wxnav/addtop')}"><i class="icon-font"></i>新增顶级导航</a>
                       
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>栏目名称</th>
							<th>类别</th>
                            <th>排序[数值大的在前面]</th>
                            <th>操作</th>
                        </tr>
						  <foreach name="re" item="v">
                        <tr>
						    <td style="text-align:left;">
							
							<if condition="$v.cid eq 0">
							[主菜单]
							</if>
							&nbsp;&nbsp;{$v.mark}{$v.mark}{$v.mark}{$v.mark}{$v.mark}{$v.mark} {$v.title}</td>
							<td>
							 
							     {$v.type}
								  
								 
							 
							</td>
                            <td >
						      <input type="text" class="mysort{$v.id}" value="{$v.sort}" onblur="savesort({$v.id})" style="text-align:center;width:50px;" />
                            </td>
                            <td>
							    <if condition="$v.cid eq 0">
								<a class="link-update" href="{:U('Wxnav/addson',array('id'=>$v['id']))}">添加子栏目</a>
								</if>
                                <a class="link-update" href="{:U('Wxnav/save',array('id'=>$v['id']))}">修改</a>
                                <a class="link-del" onclick="del({$v.id})" style="cursor:pointer;">删除</a>
                            </td>
                        </tr>
						  </foreach>
                         <tr>
                              
                                <td colspan="5">
                                    <input class="btn btn-primary btn6 mr10" value="生成微信菜单" type="button" onclick="dosubmit()">
                                    <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>

                    </table>
                  
                </div>
            </form>
        </div>
    </div>
    <script>
	   
	   function savesort(i){
	   
	     var newsort=$('.mysort'+i).val();
	     $.post("{:U('Wxnav/savesort')}",{"id":i,"sort":newsort},function(re){
		   
		   if(re==1){
		   
		   layer.tips('配置成功', '.mysort'+i);
		   }else{
		   
		     alert('设置失败');
		   
		   }
		 
		 
		 })
	   
	   
	   }
	  
	   function dosubmit(){
	       
		   var loading=layer.msg('正在生成菜单，请勿关闭或刷新页面', {icon: 16,time: 100000});
		   //layer.close(loading);
	      $.post('{:U("Caidan/sc")}',function(re){
		    layer.closeAll(); 
		    if(re==1){
			  
			 
			 
			 layer.alert('您已经重新生成公众号菜单，根据微信规则，重新关注公众号即可显示，或者不重新关注24小时后可以看到最新生成的菜单', {icon: 6});
			
			}else{
			 alert('生成菜单失败');
			}
		  
		  
		  })
	   
	   
	   }
	
	   function del(i){
	   
	     if(confirm('您确定删除吗')){
	      
		  $.post("{:U('Wxnav/del')}",{"id":i},function(re){
		  
		    if(re.msg==3){
			  
			  alert('该栏目下有子栏目请先删除');
			  return;
			}
			
			if(re.msg==1){
			  
			  alert('删除成功');
			  location.reload();
              return;			
			}
			
			if(re.msg==2){
			
			  alert('删除失败');
			}
		  
		  })
	   
	     }
	   }
	</script>